USE [CTEM-DB-v1]
GO

/****** Object:  StoredProcedure [dbo].[Ledger_search]    Script Date: 02/10/2012 11:18:31 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO




-- =============================================
-- Author:		TienDH
-- Create date: 12/05/2011
-- Description:	Get full employee's information
-- =============================================
CREATE PROCEDURE [dbo].[Ledger_search]
		@Name			 nvarchar(50),
		@Type			 nvarchar(50),
		@Person			 nvarchar(50),
		@Kind		     bigint,
		@FromDate		 datetime,
		@ToDate		     datetime
		
AS	
BEGIN
	SELECT	v.*,s.SpendTypeName
	FROM Ledger v
	LEFT JOIN SpendType s
	ON v.Kind = s.SpendTypeID
	WHERE v.Name like ISNULL(@Name,v.Name) 
	and v.Type = ISNULL(@Type,v.Type) 
	and v.Person like ISNULL(@Person,v.Person)
	and v.Kind = ISNULL(@Kind,v.Kind)
	and v.Date >=  @FromDate
	and v.Date <=  @ToDate
END




GO

